import logging

import jsonpath

from utils.assert_utils import database_test_utils


def extract_json_utils(case,all,resp):
    if case["jsonExdata"]:
        for key, value in eval(case["jsonExdata"]).items():
            value = jsonpath.jsonpath(resp.json(), value)[0]
            all[key] = value

        logging.info(f"4.JDBC提取，根据{case['jsonExdata']}提取数据,此时全局变量为：{all}")


def extract_sql_utils(case,all):
    if case["sqlExdata"]:
        for key, value in eval(case["sqlExdata"]).items():
            value = database_test_utils(value)
            all[key] = value

        logging.info(f"4.sql提取，根据{case['sqlExdata']}提取数据,此时全局变量为：{all}")
